<?php
namespace app\shop\model;
use app\BaseModel;
use think\facade\Db;



class PurchaseUserTmp extends BaseModel
{
    //定义表名
    protected $name = 'longbing_card_purchase_user_tmp';


    /**
     * @author chenniang
     * @DataTime: 2020-12-09 14:17
     * @功能说明:列表
     */
    public function selectList($dis){

        $data = $this->alias('a')
                ->join('longbing_card_shop_type b','a.cate_id = b.id AND b.pid = 0')
                ->where($dis)
                ->field('b.id,b.title')
                ->group('a.id')
                ->order('top desc,id desc')
                ->select()
                ->toArray();


        if(!empty($data)){

            foreach ($data as &$v){

                $v['child'] = Db::name('longbing_card_shop_type')->where(['pid'=>$v['id'],'status'=>1])->field('id,title')->select();
            }
        }

        return $data;

    }


    /**
     * @author chenniang
     * @DataTime: 2020-12-09 14:18
     * @功能说明:添加
     */
    public function dataAdd($data){

        $res = $this->insert($data);

        return $res;

    }


    /**
     * @author chenniang
     * @DataTime: 2020-12-09 14:20
     * @功能说明:
     */
    public function dataDel($dis){

        $res = $this->where($dis)->delete();

        return $res;

    }





}